Crate ccm[][src]

Expand description

Counter with CBC-MAC (CCM): Authenticated Encryption and Associated Data (AEAD) algorithm generic over block ciphers with block size equal to 128 bits as specified in RFC 3610.

Usage

Simple usage (allocating, no associated data):

use ccm::{Ccm, consts::{U10, U13}};
use ccm::aead::{Aead, NewAead, generic_array::GenericArray};
use aes::Aes256;

// AES-CCM type with tag and nonce size equal to 10 and 13 bytes respectively
type AesCcm = Ccm<Aes256, U10, U13>;

let key = GenericArray::from_slice(b"an example very very secret key.");
let cipher = AesCcm::new(key);

let nonce = GenericArray::from_slice(b"unique nonce."); // 13-bytes; unique per message

let ciphertext = cipher.encrypt(nonce, b"plaintext message".as_ref())
    .expect("encryption failure!"); // NOTE: handle this error to avoid panics!

let plaintext = cipher.decrypt(nonce, ciphertext.as_ref())
    .expect("decryption failure!"); // NOTE: handle this error to avoid panics!

assert_eq!(&plaintext, b"plaintext message");

This crate implements traits from the aead crate and is capable to perfrom encryption and decryption in-place wihout relying on alloc.

Re-exports

pub use aead;

Modules

Type aliases for many constants.

Structs

CCM instance generic over an underlying block cipher.

Traits

Trait implemented for valid nonce sizes, i.e. U7, U8, U9, U10, U11, U12, and U13.

Trait implemented for valid tag sizes, i.e. U4, U6, U8, U10, U12, U14, and U12.

Type Definitions

CCM nonces

CCM tags